<?php
/**
 * 会员级别控制器
 *
 * @package    app
 * @version    1.0
 * @author     Ray 33705910@qq.com
 * @license    MIT License
 * @copyright  2013 - 2015 Ray
 * @link       http://wangxiaolei.cn
 */

/**
 * 本控制器主要用于：
 * 1.
 * @package  app
 * @extends  Controller
 */
namespace admin;

class Controller_MemberLevel extends  \Controller_BaseController {

	public $template = 'edu/template';

	public function action_index(){
		$params = array(
  			'title' => '会员级别管理',
  			'menu' => ''
  		);

		$params['items'] = \Model_Member::getItems('*', null, array('people'));
		$params['levels'] = \Model_MemberLevel::getItems();

  		\View::set_global($params);
		$this->template->content = \View::forge("edu/member/members");
	}

	/**
	* 新增一个会员
	*
	* @return
	*/
	public function action_create(){
		$member = \Model_Member::forge(\Input::post());
	}

	/**
	* 编辑会员资料
	*
	* @param $id int 会员ID
	* @return
	*/
	public function action_edit($id){
		if( ! $id){
			die('无效的参数');
		}
		$member = \Model_Member::find($id);
		if($member){
			$member->set(\Input::post());
			$member->save();
		}
	}

	/**
	* 删除一个会员
	*
	* @param $id int 会员ID
	* @return
	*/
	public function action_delete($id){
		if( ! $id){
			die('无效的参数');
		}
		$member = \Model_Member::find($id);
		if($member){
			$member->is_delete = 1;
			$member->save();
		}
	}

}
